/**
 * @name 配置文件初始化
 * @description 关于配置类文件的优先级  基础配置 > 默认配置 > 包配置
 * @version 0.0.1
 * @author xiech
 * @Time 2022年03月28日11:58:47
 */
import packageconfig from './config.package';
import globalconfig from './config.global';

class config {
  constructor(options) {
    options = options || {};
    Object.assign(this, globalconfig, options);
    this.package = [];
    for (let i = 0; i < packageconfig.length; i++) {
      let _packageconfig = packageconfig[i];
      if (this[packageconfig[i].key]) {
        _packageconfig.enable = this[packageconfig[i].key].enable;
        _packageconfig.parameter = Object.assign(_packageconfig.parameter, this[packageconfig[i].key].parameter);
        delete this[packageconfig[i].key];
      }
      if (_packageconfig.enable) {
        this.package.push(_packageconfig);
      }
    }
  }
}
export default config;